<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 -->
    <el-card class="box-card">
      <el-row :gutter="20">
        <!-- input 搜索框 -->
        <el-col :span="8">
          <el-input placeholder="请输入内容" v-model="orderUser" class="input-with-select">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!-- 表格区域 -->
      <el-table :data="orderList" style="width: 100%">
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column prop="order_number" label="订单编号"></el-table-column>
        <el-table-column prop="order_price" label="订单价格"></el-table-column>
        <el-table-column prop="pay_status" label="是否付款">
          <template slot-scope="scopde">
            <el-tag type="danger" v-if="scopde.row.pay_status==='0'">未付款</el-tag>
            <el-tag v-else>已付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column prop="create_time" label="下单时间">
          <template slot-scope="scoped">{{scoped.row.create_time | dataForm}}</template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scoped">
            <el-button type="primary" size="mini" icon="el-icon-edit" @click="editRess"></el-button>
            <el-button
              type="success"
              size="mini"
              icon="el-icon-location-outline"
              @click="EditRessList(scoped.row)"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 实现分页功能 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[1, 3, 5, 10]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
      <!-- 对话框 -->
      <el-dialog title="提示" :visible.sync="ressDialogVisible" width="50%">
        <span>
          <!-- 级联选择器 -->
          <el-cascader
            v-model="ressValue"
            :options="ressOrder"
            :props="{ expandTrigger: 'hover' }"
            @change="handleChange"
          ></el-cascader>
        </span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="ressDialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="ressDialogVisible = false">确 定</el-button>
        </span>
      </el-dialog>
      <!-- 对话框 -->
      <el-dialog title="查看物流信息" :visible.sync="proceDialogVisible" width="50%">
        <span>
          <!-- 事件线 -->
          <el-timeline :reverse="false">
            <el-timeline-item
              v-for="(activity, index) in activities"
              :key="index"
              :timestamp="activity.time"
            >{{activity.context}}</el-timeline-item>
          </el-timeline>
        </span>
      </el-dialog>
    </el-card>
  </div>
</template>
<script>
import ressOrder from './citydata'
export default {
  data () {
    return {
      // 输入框内容
      orderUser: '',
      //   获取的订单数据
      orderList: [],
      //   声明数据列表
      queryInfo: {
        query: '',
        pagenum: 1,
        pagesize: 5
      },
      //   数据总数
      total: 0,
      ressValue: '',
      ressOrder: ressOrder,
      ressDialogVisible: false,
      proceDialogVisible: false,
      activities: []
    }
  },
  created () {
    this.getOrderList()
  },
  methods: {
    async getOrderList () {
      const { data: res } = await this.$http.get('orders', {
        params: this.queryInfo
      })
      this.total = res.data.total
      this.orderList = res.data.goods
      console.log(res)
    },
    // 分页
    handleSizeChange (size) {
      this.queryInfo.pagesize = size
      this.getOrderList()
    },
    handleCurrentChange (pagenull) {
      this.queryInfo.pagenum = pagenull
      this.getOrderList()
    },
    editRess () {
      this.ressDialogVisible = true
    },
    handleChange () {},
    async EditRessList (id) {
      const { data: res } = await this.$http.get('/kuaidi/1106975712662')
      console.log(res)
      this.activities = res.data
      this.proceDialogVisible = true
    }
  }
}
</script>
<style lang="less" scoped>
/deep/ .el-input__inner {
  border: 1px solid #ccc !important;
}
/deep/ .el-timeline-item__node {
  background-color: #ffA500;
}
</style>
